import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
// import { NaiveUiResolver } from "unplugin-vue-components/resolvers";
import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
import { TDesignResolver } from "unplugin-vue-components/resolvers";
import path from "path";
import { viteExternalsPlugin } from "vite-plugin-externals";
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    viteExternalsPlugin({
      rasterTileLayer: "rasterTileLayer",
    }),
    AutoImport({
      imports: [
        "vue",
        // {
        //   "naive-ui": [
        //     "useDialog",
        //     "useMessage",
        //     "useNotification",
        //     "useLoadingBar",
        //   ],
        // },
      ],
      resolvers: [
        TDesignResolver({
          library: "mobile-vue",
        }),
      ],
    }),

    Components({
      resolvers: [
        TDesignResolver({
          library: "mobile-vue",
        }),
      ],
    }),
    createSvgIconsPlugin({
      // 指定需要缓存的图标文件夹
      iconDirs: [path.resolve(process.cwd(), "src/assets/icons")],
      // 指定symbolId格式
      symbolId: "icon-[dir]-[name]",

      /**
       * 自定义插入位置
       * @default: body-last
       */
      // inject?: 'body-last' | 'body-first'

      /**
       * custom dom id
       * @default: __svg__icons__dom__
       */
      // customDomId: '__svg__icons__dom__',
    }),
  ],
  base: "/keep/",
  // 配置文件引用别名 alias
  resolve: {
    alias: [
      {
        find: "@",
        replacement: path.resolve(__dirname, "./src"),
      },
    ],
  },
  server: {
    host: "0.0.0.0",
    port: 8005,
  },
  css: {
    // preprocessorOptions: {
    //   scss: {
    //     additionalData:
    //       '@use "./node_modules/element-plus/theme-chalk/src/dark/css-vars.scss" as *;',
    //   },
    // },
  },
});
